
#
# Factory of player objects
#
class PlayerFactory
  @singleton_w3c_player: null
  @singleton_mozzila_player: null

  #
  # create player object
  #
  @create:(controller)->
      if W3CPlayer.available_api()
        if @singleton_w3c_player is null
          @singleton_w3c_player = new W3CPlayer(controller)
        return @singleton_w3c_player

      else if MozillaPlayer.available_api(controller)
#          var audio = new Audio();
#          if (typeof(audio.mozWriteAudio) != "undefined") {
#              var rate = 48000;
#               audio.mozSetup(1, rate);
#              setInterval(function() {
#                  var buf = getbuf(buflen, rate);
#                  audio.mozWriteAudio(buf);
#              }, buflen / rate * 1000);
#         }
      else
        console.log('No audio API is available.')
        return null
